package com.hexacta.hrs.repositories.impl;

import java.util.List;

import com.hexacta.hrs.domain.staffing.Client;
import com.hexacta.hrs.repositories.ClientRepository;

public class ClientRepositoryHibernateTemplateImpl extends HibernateRecordObjectRepository<Client> implements ClientRepository {
	public ClientRepositoryHibernateTemplateImpl(Class<Client> entityClass) {
		super(entityClass);
	}

	public void saveOrUpdate(Object o) {
        this.getHibernateTemplate().saveOrUpdate(o);
        return;
    }
    
    public void delete(Client client) {
        this.getHibernateTemplate().delete(client);
    }
    
    public Client findById(long id) {
    	Client client = (Client) this.getHibernateTemplate().get(Client.class, Long.valueOf(id));
    	return client;
    }
    
    @SuppressWarnings("unchecked")
    public List<Client> findByName(String name) {
    	List<Client> clients = this.getHibernateTemplate().find("from " + Client.class.getSimpleName() + " where name = '" + name + "'");
    	return clients;
    }
    
    @SuppressWarnings("unchecked")
	public List<Client> findAll() {
    	List<Client> projects = this.getHibernateTemplate().find("from " + Client.class.getSimpleName());
    	return projects;
    }
}
